﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WHC.Hotel.Entity;
using WHC.Hotel.BLL;
using WHC.OrderWater.Commons;

namespace WHC.Hotel.UI
{
    public partial class FrmShowCanUseRoomm:BaseForm
    {

        public RoomInfo roomInfo = null;
        public BookInfo bookInfo = null;
        private string selectRoomNo = string.Empty;
        public FrmShowCanUseRoomm()
        {
            InitializeComponent();
        }

        private void FrmShowCanUseRoomm_Load(object sender, EventArgs e)
        {
            this.dgRoom.AutoGenerateColumns = false;
            groupBox1.Text = "房间类型："+bookInfo.RoomType + "(单价：" + BLLFactory<RoomType>.Instance.FindByName(bookInfo.RoomType).DayPrice + ")--可用房间"; 
            ShowCanUseRoom();
        }

        /// <summary>
        /// 获取可能房间列表
        /// </summary>
        private void ShowCanUseRoom()
        {

            SearchCondition condition = new SearchCondition();
            condition.AddCondition("RoomType", bookInfo.RoomType, SqlOperator.Equal, true);
            condition.AddCondition("Status", "'空净房','空脏房'", SqlOperator.In, false);
            string sql = condition.BuildConditionSql(DatabaseType.SqlServer).Replace("Where", "");
            this.dgRoom.DataSource = BLLFactory<Room>.Instance.FindToDataTable(sql);
        
        
        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(selectRoomNo))
            {


                MessageUtil.ShowTips("请选择一个房间");
                return;

            
            }


            if (MessageUtil.ShowYesNoAndTips("确定选择房间" + selectRoomNo + "") == DialogResult.Yes)
            {

                roomInfo = BLLFactory<Room>.Instance.FindByRoomNo(selectRoomNo);
                this.DialogResult = DialogResult.OK;

            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dgRoom_SelectionChanged(object sender, EventArgs e)
        {


            if (dgRoom.CurrentRow != null)
            {
               selectRoomNo = dgRoom.CurrentRow.Cells["RoomNo"].Value.ToString();
               
            }
        }


    }
}
